/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1619657754424_8629';

  // add your middleware config here
  config.middleware = ['errorHandler', 'wxUserAuth', 'adminUserAuth','shopUserAuth'];
  config.wxUserAuth = {//小程序登录
    // ignore: ['/banner/list','/class/edit']
    match: ['/app/login/userinfo', '/app/coupons','/app/my','/app/agent','/app/bank'],//设置只有符合某些规则的请求才会经过这个中间件
  };
  config.adminUserAuth = {//admin 登录
    match: ['/admin/user/edit','/admin/user/list','/admin/user/del','/admin/user/setpower','/admin/user/userInfo','/admin/user/repwd', '/admin/depart','/admin/nav','/admin/btn','/admin/adminUpload','/admin/city','/admin/class','/admin/hot','/admin/shop','/admin/banner','/admin/feedback','/admin/file','/admin/coupons','/admin/bank'],//设置只有符合某些规则的请求才会经过这个中间件
  };
  config.shopUserAuth = {//小程序  商家登录
    // ignore: ['/banner/list','/class/edit']
    match: ['/app/shop'],//设置只有符合某些规则的请求才会经过这个中间件
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  config.security = {
    // 关闭 csrf
    csrf: {
      enable: false,
    },
    // 跨域白名单
    domainWhiteList: [],
  };
  // 允许跨域的方法
  config.cors = {
    origin: '*',
    allowMethods: 'GET, PUT, POST, DELETE, PATCH'
  };
  // 数据库
  config.sequelize = {
    dialect: 'mysql',
    host: 'www.woniukj.vip',
    username: 'eggYhq',
    password: 'eggYhq123456',
    port: 3306,
    database: 'egg-yhq',
    // 中国时区
    timezone: '+08:00',
    define: {
      // 取消数据表名复数
      freezeTableName: true,
      // 自动写入时间戳 created_at updated_at
      timestamps: true,
      // 字段生成软删除时间戳 deleted_at
      // paranoid: true,
      createdAt: 'created_at',
      updatedAt: 'updated_at',
      // deletedAt: 'deleted_at',
      // 所有驼峰命名格式化
      underscored: true
    }
  };
  // redis
  config.redis = {
    client: {
      port: 6379,          // Redis port
      host: '127.0.0.1',   // Redis host
      password: '',
      db: 1,
    },
  };
  config.multipart = {
    mode: 'file'
  };
  // oss存储
  config.oss = {
    client: {
      accessKeyId: 'LTAI4FfZsFvo82idmCygo8Gz',
      accessKeySecret: 'miyQBNXhdDhK9KgoIBn6wPUV7cKFxU',
      bucket: 'egg-yhq',
      endpoint: 'oss-cn-chengdu.aliyuncs.com',
      timeout: '60s',
    },
  };


  config.crypto = {
    secret: 'qhdgw@45ncashda1ksh2!#@3nxjdas*_672'
  };
  config.jwt = {
    secret: 'qhdgw@45ncash123daksh2!#@3nxjdas*_672'
  };
  config.valparams = {
    locale: 'zh-cn',
    throwError: true
  };
  // // 小程序 参数
  config.appConfig = {
    wx: { // 微信小程序
      appid: 'wxc970888be9d0bf90',
      secret: '9015d27a762f2510a8da800d383066fb',
    },
    // two: { // 阿龙团拼小程序
    //   appid: '',
    //   secret: '',
    // },
  };



  return {
    ...config,
    ...userConfig,
  };
};
